﻿using System;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using System.Web.UI.MobileControls;
using System.Collections.Generic;

public partial class EarlyWarning_WarningMap : BasePage
{
    public EarlyWarning_WarningMap()
    { }
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected string GetWarninglight()
    {
        HZ.Supervise.IBLL.IBLL_PreWarning ipw = HZ.Supervise.BLLFactory.IBLL_PreWarning();

        StringBuilder sb = new StringBuilder();
        DataTable dt = ipw.GetWarningArea();

        List<WarningLight> list = new List<WarningLight>();
        foreach (DataRow item in dt.Rows)
        {
            //list.Add(new WarningLight() { AreaID = item["AreaID"].ToString(),AreaName=item["AreaName"].ToString(), WarningLevel = (int)item["WarningLevel"] });
            list.Add(new WarningLight() { AreaID = "320100", AreaName = item["AreaName"].ToString(), WarningLevel = (int)item["WarningLevel"] });
        }

        foreach (var item in list)
        {
            sb.AppendLine(item.ToString());
        }
        return sb.ToString();
    }
}

public class WarningLight
{
    public string AreaID { get; set; }

    public string AreaName { get; set; }

    public int WarningLevel { get; set; }

    public override string ToString()
    {
        // return base.ToString();
        string str = string.Empty;
        if (WarningLevel == 1)
        {
            str = string.Format(string.Format("<a href=\"DrugPreWarning_CL.aspx?AreaID={0}\" id=\"a{0}\" ><font color=\"red\">{1}<font></a>", AreaID, AreaName));
        }
        else if (WarningLevel == 2)
        {
            str = string.Format(string.Format("<a href=\"DrugPreWarning_CL.aspx?AreaID={0}\" id=\"a{0}\" ><font color=\"blue\">{1}<font></a>", AreaID, AreaName));
        }
        else
        {
            str = string.Format(string.Format("<a href=\"DrugPreWarning_CL.aspx?AreaID={0}\" id=\"a{0}\" ><font color=\"green\">{1}<font></a>", AreaID, AreaName));
        }

        return str;

    }

}